// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <cantor/unresolved/visitor.h>

namespace cantor::unresolved {
    class UnresolvedFieldsClause;
    class UnresolvedLinesClause;
    class UnresolvedColumnName;
    class UnresolvedTableName;
    class UnresolvedAssignment;

    class UnresolvedLoadDataStmt : public UnresolvedVisitor<UnresolvedLoadDataStmt> {
    public:
        static constexpr const cantor::pb::ast::StmtType TYPE = cantor::pb::ast::StmtType::STMT_LOAD_DATA;

        UnresolvedLoadDataStmt(const cantor::pb::ast::LoadDataStmt &node) : instance(node) {
        }

        UnresolvedLoadDataStmt(const cantor::pb::ast::Statement &node) : instance(node.load_data_stmt()) {
        }

        ~UnresolvedLoadDataStmt() override = default;

        const pb::Location &location_impl() const {
            return instance.location();
        }

        const pb::Status &error_status_impl() const {
            return instance.status();
        }

        int32_t ignore_lines() const {
            return instance.ignore_lines();
        }

        bool is_local() const {
            return instance.is_local();
        }

        std::string_view path() const {
            return instance.path();
        }

        std::string_view char_set() const {
            return instance.char_set();
        }

        bool has_fields_info() const {
            return instance.has_fields_info();
        }

        UnresolvedFieldsClause fields_info() const;

        bool has_lines_info() const {
            return instance.has_lines_info();
        }

        UnresolvedLinesClause lines_info() const;

        bool has_table_name() const {
            return instance.has_table_name();
        }

        UnresolvedTableName table_name() const;

        pb::ast::OnDuplicateKeyHandle on_duplicate_handle() const {
            return instance.on_duplicate_handle();
        }

        size_t columns_size() const {
            return instance.columns_size();
        }

        UnresolvedColumnName columns(int index) const;

        size_t set_list_size() const {
            return instance.set_list_size();
        }

        UnresolvedAssignment set_list(int index) const;

        const cantor::pb::ast::LoadDataStmt &instance;
    };
} // namespace cantor::unresolved
